<?php
// $Id: user-profile.tpl.php,v 1.2.2.1 2008/10/15 13:52:04 dries Exp $

/**
 * @file user-profile.tpl.php
 * Default theme implementation to present all user profile data.
 *
 * This template is used when viewing a registered member's profile page,
 * e.g., example.com/user/123. 123 being the users ID.
 *
 * By default, all user profile data is printed out with the $user_profile
 * variable. If there is a need to break it up you can use $profile instead.
 * It is keyed to the name of each category or other data attached to the
 * account. If it is a category it will contain all the profile items. By
 * default $profile['summary'] is provided which contains data on the user's
 * history. Other data can be included by modules. $profile['user_picture'] is
 * available by default showing the account picture.
 *
 * Also keep in mind that profile items and their categories can be defined by
 * site administrators. They are also available within $profile. For example,
 * if a site is configured with a category of "contact" with
 * fields for of addresses, phone numbers and other related info, then doing a
 * straight print of $profile['contact'] will output everything in the
 * category. This is useful for altering source order and adding custom
 * markup for the group.
 *
 * To check for all available data within $profile, use the code below.
 *
 * @code
 *   print '<pre>'. check_plain(print_r($profile, 1)) .'</pre>';
 * @endcode
 *
 * @see user-profile-category.tpl.php
 *   Where the html is handled for the group.
 * @see user-profile-field.tpl.php
 *   Where the html is handled for each item in the group.
 *
 * Available variables:
 *   - $user_profile: All user profile data. Ready for print.
 *   - $profile: Keyed array of profile categories and their items or other data
 *     provided by modules.
 *
 * @see template_preprocess_user_profile()
 */
 //d($account->uid);
 //fe($profile);
 global $user;
 $info = shvabr_get_user_info($account->uid);
 //fe($info);
?>
<div class="profile">	
	<table class="profile"><tr>
  <?php   	
  	print	"<td>";
  	// karma
  	print	"<h3>Карма</h3>";
  	print	"<strong>Карма: </strong>" . $account->karma . "<br>\n";
  	print	"<strong>Место в рейтинге: </strong>" . $account->rank . "<br><br>\n";
  	
  	// status
  	// Можно выводить только последний статус:
  	//print $profile['facebook_status'];
  	// А можно сразу стандартную вьюху, идущую в комплеке с модулем Facebook statuses, которая выводит последние статусы юзера:
  	print	"<h3>Микроблог</h3>";
  	if($info["is_microblog"]) {
  		print views_embed_view('facebook_status', 'page_1', $account->uid);
  	} else {
  		if($user->uid != $account->uid) {
  			print	"В микроблоге псуто :(<br><br>\n";
  		} else {
  			print	"В вашем микроблоге псуто :(<br><br>\n";  			
  		}
  	}
  	// Но для владельца аккаунта все равно надо показать стандартную форму, через нее он сможет обновлять свой статус:
  	if($user->uid == $account->uid) {
  		print $profile['facebook_status'];
  	}
  	print	'<a href="' . base_path() . drupal_get_path_alias("blog/" . $account->uid). '">Последние записи в блоге</a><br>';
  	
  	// custom profile fields
  	print	$profile['content_profile'];
  	
  	// user visits
  	print	"<h3>Последние посетители</h3>";
  	print	$account->content['summary']['user_visits']['#value'];
  	
  	// friends
  	if(count($info['friends'])) {
  		print	"<h3>Друзья</h3>";
  		foreach($info['friends'] as $friend) {
  			if(isset($friend->picture) && trim($friend->picture) != "") {			  	
			  	print '<div style="float: left; margin: 3px 3px 0 0;"><a href="' . drupal_get_path_alias("user/" . $friend->uid) . '"><img src="' . base_path() . $friend->picture . '" alt="' . $friend->name . '" title="' . $friend->name . '"></a></div>';
			  } else {
			  	print ' <div class="name">'. theme('username', $friend) .'</div>'."\n";
			  }
  		}
  	}
  	
  	
  	print "</td>";
  	print	"<td>";
  	// wall
  	if(count($info['guestbook'])) {
  		print	"<h3>Стена</h3>";
  		$rows = array();
  		foreach($info['guestbook'] as $message) {
  			$rows[] = array(l($message['name'], drupal_get_path_alias("user/" . $message['author'])), $message['message']);
  		}
  		if($user->uid != $account->uid) {
  			$rows[] = array(array('data' => l("Напис<em>а</em>ть на стене!", drupal_get_path_alias("user/" . $account->uid . "/guestbook"), array('html' => TRUE)), 'colspan' => 2, 'style' => 'text-align: right;'));
  		}
  		$header = array();
  		print	theme('table', $header, $rows);
  	} else {
  		print	"<h3>Стена</h3>";
  		if($user->uid != $account->uid) {
  			print	theme('table', array(), array(array("На стене пока пусто, " . l("вы можете первым оставить свой след здесь!", drupal_get_path_alias("user/" . $account->uid . "/guestbook")))));
  		} else {
  			print	theme('table', array(), array(array("На вашей стене пока пусто :(")));
  		}
  	}
  	
  	//photos
  	if(count($info['personal_galleries'])) {
  		print	"<h3>Фотогалереи пользователя</h3>";
	  	foreach($info['personal_galleries'] as $gallery) {
	  		print	"<h4>" . l($gallery["title"], "node/" . $gallery['nid']) . "</h4>";
	  		foreach($info['photos'][$gallery['nid']] as $photo) {
	  			print	l(theme("imagecache", "small", $photo["filepath"], $photo["title"], $photo["title"], array('style' => 'margin-right: 5px;')), drupal_get_path_alias("node/" . $photo["nid"]), array('html' => TRUE));
	  		}
	  	}
  	}
  	print	"</td>";
  	//print $user_profile; 
  	//fe($profile);
  ?>
	</tr></table>
</div>
 